<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //数组初始化
        let arr = new Array(1, 2, 3, 4, 5);
        let arr2 = ['zhangsan', 'lisi', `laowu`];
        console.log(arr2.length);

        //数组新增元素push
        let len = arr.push(12, 8, 9)//添加元素到数组末尾,会返回新数组的长度
        console.log(len);
        for (let I = 0; I < arr.length; I++) {
            const element = arr[I];
            console.log(arr[I]);
        }
        //数组新增函数unshift
        arr2.unshift('yuhui', 'rihao');
        for (let I = 0; I < arr2.length; I++) {
            const element = arr2[I];
            console.log(arr2[I]);
        }
    </script>
</body>

</html>